home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 10 Nov 1998
- // Author: spam
- //
- // Description:
- // Procs for creating the Component Editor Window.
- //
- //
- ////////////////////////////////////////////////////////////////////////////////
-
-
- // Procedure Name:
- // compEdPrecisionPrompt
- //
- // Description:
- // Prompts user to enter a new integer for the number of decimal
- // points to show.
- //
- // Return Value:
- // None.
- //
- global proc compEdPrecisionPrompt ()
- {
- int $oldPrecision = `optionVar -query CEPrecision`;
- int $newPrecision = precisionPrompt ("componentEditorPanel1Window", $oldPrecision, 15);
- if ($newPrecision > 0) {
- componentEditor -edit -pre $newPrecision componentEditorPanel1WindowComponEditor;
- optionVar -iv CEPrecision $newPrecision;
- }
- }
-
-
- global proc buildCompEdContextHelpItems(string $nameRoot, string $menuParent)
- //
- // Description:
- // Build context sensitive menu items for the hyper graph.
- //
- // Input Arguments:
- // $nameRoot - name to use as the root of all item names
- // $menuParent - the name of the parent of this menu
- //
- // Return Value:
- // None
- //
- {
- menuItem -label "Help on Component Editor..."
- -enableCommandRepeat false
- -command "showHelp ComponentEditor";
- }
-
-
- //
- // Procedure Name:
- // buildCompEdMenus
- //
- // Description:
- // Build all of the menus needed for the component editor window
- //
- // Input Arguments:
- // string $compEdName - the name of the component editor
- //
- // Return Value:
- // None
- //
- global proc buildCompEdMenus(string $compEdName) {
-
- int $isChecked;
-
- // assume that the menu parent is properly set.
- //
- menu -l "List"
- -tearOff true
- -postMenuCommandOnce true
- -familyImage "menuIconOptions.xpm";
-
- // the menuItems
- //
- // autoupdate = default to on
- //
- if(`optionVar -exists CEAutoUpdate`) {
- $isChecked = `optionVar -q CEAutoUpdate`;
- } else {
- $isChecked = true;
- optionVar -iv CEAutoUpdate true;
- }
- string $mitem = `menuItem -l "Auto Update" -checkBox $isChecked
- -command ("compEdMenuCmd CEMIAutoUpdate " + $compEdName)
- "CEMIAutoUpdate"`;
-
- string $mitem = `menuItem -l "Load Selected Components"
- -command ("compEdMenuCmd CEMILoad " + $compEdName)
- "CEMILoad"`;
-
- // showAllCols defaults to on
- //
- int $showCols;
- if(`optionVar -exists CEShowAllCols`) {
- $showCols = `optionVar -q CEShowAllCols`;
- } else {
- $showCols = true;
- optionVar -iv CEShowAllCols true;
- }
- string $mitem = `menuItem -l "Show All Columns" -checkBox $showCols
- -command ("compEdMenuCmd CEMIShowAllCols " + $compEdName)
- -annotation "Show All Columns: Turn off to hide columns that contain only zero values"
- "CEMIShowAllCols"`;
-
- // show path name defaults to on
- //
- int $showPathName;
- if(`optionVar -exists CEShowPathName`) {
- $showPathName = `optionVar -q CEShowPathName`;
- } else {
- $showCols = true;
- optionVar -iv CEShowPathName true;
- }
- string $mitem = `menuItem -l "Show Path Name" -checkBox $showPathName
- -command ("compEdMenuCmd CEMIShowPathName " + $compEdName)
- -annotation "Show Path Name: Turn off to hide path names and only show object name"
- "CEMIShowPathName"`;
-
-
- menuItem -label "Change Precision..." -command "compEdPrecisionPrompt";
-
- setParent -menu ..;
-
- // Add support for the Context Sensitive Help Menu.
- //
- addContextHelpProc $compEdName "buildCompEdContextHelpItems";
- // doHelpMenu($compEdName, $compEdName);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // compEdMenuCmd
- //
- // Description:
- // The command called by all comp ed menus
- //
- // Input Arguments:
- // string $itemName - the nema of the menuItem
- // string $compEdName - the name of the component editor
- //
- // Return Value:
- // None
- //
- global proc compEdMenuCmd(string $itemName, string $compEdName) {
-
- if( `menuItem -exists $itemName` ) {
-
- if ($itemName == "CEMIAutoUpdate") {
-
- int $isChecked = `menuItem -q -checkBox $itemName`;
-
- if($isChecked) {
- componentEditor -e -li false $compEdName;
- } else {
- componentEditor -e -li true $compEdName;
- }
- } else if ($itemName == "CEMILoad") {
- componentEditor -e -li false $compEdName;
- componentEditor -e -li true $compEdName;
- } else if ($itemName == "CEMIShowAllCols") {
- int $isChecked = `menuItem -q -checkBox $itemName`;
-
- if($isChecked) {
- componentEditor -e -hzc false $compEdName;
- } else {
- componentEditor -e -hzc true $compEdName;
- }
- } else if ($itemName == "CEMIShowPathName") {
- int $isChecked = `menuItem -q -checkBox $itemName`;
-
- if($isChecked) {
- componentEditor -e -hpn false $compEdName;
- } else {
- componentEditor -e -hpn true $compEdName;
- }
- }
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // setTabOpType
- //
- // Description:
- // Set the given componentEditor to the currentTabIndex-1 th
- // opeartionType, or to a hardcoded given value.
- //
- // Input Arguments:
- // string $tabLayoutName - name of the tab layout in the window
- // string $compEdName - name of the component editor in the window
- // int $set - if not -1, will set the tabLayout to that number.
- // if -1, will query the tabLayout. So When the editor first
- // comes up, set will be a saved value, allowing the editor
- // the last tab it was open to. The -1 is used as a parameter
- // when this command is added as tab changed command.
- //
- // Return Value:
- // None
- //
- global proc setTabOpType(string $tabLayoutName, string $compEdName, int $set) {
-
- if (`tabLayout -exists $tabLayoutName`) {
- int $currentTab = $set;
- if( $set == -1) {
- $currentTab = `tabLayout -q -selectTabIndex $tabLayoutName`;
- }
-
- optionVar -intValue "CEoperationType" $currentTab;
-
- // subtract 1 since tabs are a 1-based index, and
- // component editor uses a zero based index.
- //
- $currentTab -= 1;
-
- // for safety's sake, verify that the current tab is valid.
- //
- int $maxTabs = `componentEditor -q -operationCount $compEdName`;
- if($currentTab <= $maxTabs) {
- componentEditor -e -operationType $currentTab $compEdName;
- }
- }
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // updateComponentEditorSliderRange
- //
- // Description:
- // Callback for when a value is changed in one of the fields that
- // controls the slider's range
- //
- // Input Arguments:
- // $slider - the slider used to edit groups of values in the component
- // editor
- // $minField - field for setting the min value of the slider
- // $maxField - field for setting the max value of the slider
- //
- // Return Value:
- // None
- //
- global proc updateComponentEditorSliderRange( string $slider,
- string $minField,
- string $maxField )
- {
- float $min, $max;
-
- $min = `floatField -q -value $minField`;
- $max = `floatField -q -value $maxField`;
-
-
- if ( $max > $min ) {
- floatSlider -e -minValue $min -maxValue $max $slider;
-
- // Update option vars
- //
- optionVar -fv "componentEditorSliderMin" $min;
- optionVar -fv "componentEditorSliderMax" $max;
- } else {
- warning( "Slider maximum must be greater than minimum" );
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // initComponentEditorSlider
- //
- // Description:
- // Set up the optionVars and initialize the slider range
- //
- // Input Arguments:
- // $slider - the slider used to edit groups of values in the component
- // editor
- // $minField - field for setting the min value of the slider
- // $maxField - field for setting the max value of the slider
- //
- // Return Value:
- // None
- //
- proc initComponentEditorSlider( string $slider, string $minField,
- string $maxField )
- {
- float $min, $max;
-
- // Retrieve min value for slider
- //
- if ( !`optionVar -exists "componentEditorSliderMin"` ) {
- optionVar -fv "componentEditorSliderMin" 0.0;
- }
- $min = `optionVar -q "componentEditorSliderMin"`;
-
- // Retrieve max value for slider
- //
- if ( !`optionVar -exists "componentEditorSliderMax"` ) {
- optionVar -fv "componentEditorSliderMax" 1.0;
- }
- $max = `optionVar -q "componentEditorSliderMax"`;
-
- string $cmd = "updateComponentEditorSliderRange( \"" + $slider
- + "\", \"" + $minField + "\", \"" + $maxField + "\");";
-
- floatField -e -changeCommand $cmd -value $min $minField;
- floatField -e -changeCommand $cmd -value $max $maxField;
-
- updateComponentEditorSliderRange( $slider, $minField, $maxField );
- }
-
-
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // buildComponentEditorControls
- //
- // Description:
- // Build the component editor controls. Assumes a parent
- // MenuBarLayout has already been created.
- //
- // Input Arguments:
- // None
- //
- // Return Value:
- // None
- //
- global proc buildComponentEditorControls() {
-
- string $parent = `setParent -q`;
-
- // find and isolate the part of the parent name containing
- // the unique name of the panel
- //
- string $tokens[];
- tokenize ($parent,"|",$tokens);
- int $numTokes = `size $tokens`;
- int $j;
- for ($j = 0; $j < $numTokes; $j++) {
- string $mtchStr = `match $tokens[$j] "componentEditorPanel"`;
- int $num = `size $mtchStr`;
- if( $num == 0 ) {
- break;
- }
- }
-
- // Get the decimal precision
- //
- int $precision;
- if (!`optionVar -exists CEPrecision`) {
- optionVar -iv CEPrecision 3;
- }
- $precision = `optionVar -q CEPrecision`;
-
- // make the editor, but don't parent it yet
- //
- if (!`selectionConnection -exists ($tokens[$j] + "CESelCon")`) {
- string $spam = `selectionConnection -activeList -parent $parent ($tokens[$j] + "CESelCon")`;
- } else {
- selectionConnection -e -parent $parent ($tokens[$j] + "CESelCon");
- }
-
- string $edName = ($tokens[$j] + "ComponEditor");
-
- if(!`componentEditor -exists $edName`) {
- $edName = `componentEditor -unParent -pre $precision -mainListConnection ($tokens[$j] + "CESelCon") $edName`;
- } else {
- componentEditor -e -unParent -mainListConnection ($tokens[$j] + "CESelCon") $edName;
- }
-
- // make the menus
- //
- buildCompEdMenus($edName);
-
- string $mainForm = `formLayout compEdForm`;
-
- string $tabLayout = `tabLayout -parent $mainForm compEdTab`;
- tabLayout -e -cc ("setTabOpType " + $tabLayout + " "
- + $edName + " -1") $tabLayout;
- setParent ..;
-
- string $frameL = `frameLayout -p $mainForm -l "" compEdFrame`;
- string $compFormLayout = `formLayout`;
- int $isChecked = `optionVar -q CEAutoUpdate`;
- componentEditor -e -lockInput (!$isChecked) -parent $compFormLayout
- $edName;
-
- string $floatField = `floatField -width 75`;
- string $floatSliderMinField = `floatField -precision 2`;
- string $floatSliderMaxField = `floatField -precision 2`;
- string $floatSlider = `floatSlider`;
-
- componentEditor -e -floatSlider $floatSlider -floatField $floatField
- $edName;
-
- initComponentEditorSlider( $floatSlider, $floatSliderMinField,
- $floatSliderMaxField );
- setParent ..;
- setParent ..;
-
- string $btnForm = `formLayout buttonForm`;
-
- string $rbtn = `button -p $btnForm -l "Load Components"
- -c ("componentEditor -e -li false " + $edName +
- "; componentEditor -e -li true " + $edName)
- reloadBtn`;
-
- // close button won't exist in a non torn-off panel
- // only make it if we're in a window.
- //
- string $tokens[];
- tokenize($parent,"|",$tokens);
-
- if($tokens[0] != "MayaWindow") {
- string $cbtn = `button -p $btnForm -l "Close"
- -c ("deleteUI " + $tokens[0])
- closeBtn`;
- }
-
- setParent ..;
- setParent ..;
- setParent ..;
-
- // now construct a command to set the tab labels
- //
-
- // get the tab labels
- //
- string $labels[] = `componentEditor -q -operationLabels $edName`;
-
- // now create children of the tab layout
- //
- setParent $tabLayout;
- int $i, $numTabs = size($labels);
-
- for( $i = 0; $i < $numTabs; $i++ ) {
- formLayout ("compEdTabChild" + $i);
- separator -style "none";
- setParent ..;
- }
- setParent ..;
-
- string $tabCmd = "tabLayout -e";
- for ($i = 0; $i < $numTabs; $i++ ) {
- $tabCmd += (" -tl compEdTabChild" + $i + " \"" + $labels[$i] + "\"");
- }
- $tabCmd += " " + $tabLayout;
-
- // now set the labels
- //
- eval $tabCmd;
-
- // now set the tab type to the last remembered one
- //
- int $currentOp = `optionVar -q "CEoperationType"`;
- if($currentOp > 0 && $currentOp < $numTabs) {
- setTabOpType($tabLayout,$edName,$currentOp);
- tabLayout -e -selectTabIndex $currentOp $tabLayout;
- }
-
- // lastly, do the form attachments
- //
- formLayout -e
- -af compEdTab "top" 0
- -af compEdTab "left" 0
- -af compEdTab "right" 0
- -an compEdTab "bottom"
-
- -ac compEdFrame "top" 0 compEdTab
- // -af compEdFrame "top" 0
- -af compEdFrame "right" 0
- -af compEdFrame "left" 0
- -af compEdFrame "bottom" 30
-
- -an buttonForm "top"
- -af buttonForm "left" 3
- -af buttonForm "right" 3
- -af buttonForm "bottom" 3
-
- $mainForm;
-
- formLayout -e
- -af reloadBtn "top" 0
- -af reloadBtn "left" 0
- -ap reloadBtn "right" 1 50
- -af reloadBtn "bottom" 0
- $btnForm;
-
- formLayout -e
- -af $edName "top" 0
- -af $edName "left" 0
- -af $edName "right" 0
- -ac $edName "bottom" 5 $floatField
- -af $floatField "left" 0
- -af $floatField "bottom" 2
- -an $floatField "right"
- -an $floatField "top"
- -ac $floatSliderMinField "left" 10 $floatField
- -af $floatSliderMinField "bottom" 2
- -an $floatSliderMinField "right"
- -an $floatSliderMinField "top"
- -ac $floatSlider "left" 0 $floatSliderMinField
- -ac $floatSlider "right" 0 $floatSliderMaxField
- -an $floatSlider "bottom"
- -aoc $floatSlider "top" 4 $floatSliderMinField
- -af $floatSliderMaxField "right" 0
- -af $floatSliderMaxField "bottom" 2
- -an $floatSliderMaxField "top"
- -an $floatSliderMaxField "left"
- $compFormLayout;
-
- if($tokens[0] != "MayaWindow") {
- formLayout -e
- -af closeBtn "top" 0
- -ap closeBtn "left" 1 50
- -af closeBtn "right" 0
- -af closeBtn "bottom" 0
- $btnForm;
- }
-
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // componentEditorWindow
- //
- // Description:
- // Build the component editor window
- //
- // Input Arguments:
- // None
- //
- // Return Value:
- // None
- //
- global proc componentEditorWindow() {
-
- if ( !`window -exists componentEditorWin` ) {
-
- window -title "Component Editor"
- -iconName "Components" componentEditorWin;
-
- // now create a menuBarLayout
- //
- string $compEdMenLayout = `menuBarLayout compEdMenLayout`;
-
- buildComponentEditorControls ;
- }
-
- showWindow componentEditorWin;
-
- }
-